package com.zjitc.service.impl;

import com.github.pagehelper.PageHelper;
import com.zjitc.dao.ManageDao;
import com.zjitc.model.Category;
import com.zjitc.model.Manage;
import com.zjitc.model.Order;
import com.zjitc.model.Product;
import com.zjitc.model.User;
import com.zjitc.service.ManageService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/5/28 16:49
 * @description:
 */
@Service
public class ManageServiceImpl implements ManageService {

  @Autowired
  private ManageDao manageDao;

  @Override
  public Manage manageLoginByMname(String mname) {
    Manage manage = manageDao.manageLoginByMname(mname);
    return manage;

  }

  @Override
  public Manage manageLogin(String mname, String mpassword) {
    Manage manage = manageDao.manageLoginByMnameAndMpassword(mname,mpassword);
    return manage;
  }

  @Override
  public List<User> findAllUser(Integer pageNum, Integer count) {
    PageHelper.startPage(pageNum,count);
    List<User> userList = manageDao.findAllUser();
    return userList;
  }

  @Override
  public void deleteUser(Integer uid) {
    manageDao.deleteUser(uid);
  }

  @Override
  public List<Category> findOneProduct(Integer pageNum, Integer count) {
    PageHelper.startPage(pageNum,count);
    List<Category> categoryList = manageDao.findOneProduct();
    return categoryList;
  }

  @Override
  public Category findCid(String cid) {
    Category category =  manageDao.findCid(cid);
    return category;
  }

  @Override
  public void updateOneProduct(Category category) {
    manageDao.updateOneProduct(category);
  }

  @Override
  public List<Product> findTwoProduct(Integer pageNum, Integer count) {
    PageHelper.startPage(pageNum,count);
    List<Product> productList = manageDao.findTwoProduct();
    return productList;
  }

  @Override
  public Product findPid(Integer pid) {
    Product product = manageDao.findPid(pid);
    return product;
  }

  @Override
  public void updateTwoProduct(Product product) {
    manageDao.updateTwoProduct(product);
  }

  @Override
  public void deleteTwoProduct(Integer pid) {
    manageDao.deleteTwoProduct(pid);
  }

  @Override
  public List<Order> findOrderList(Integer pageNum, Integer count) {
    PageHelper.startPage(pageNum,count);
    List<Order> orderList = manageDao.findOrderList();
    return orderList;
  }
}
